package com.it.a05cpddemo1;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    public static void main(String[] args) throws IOException {
        /*
        TCP协议，读取数据
         */

        ServerSocket ss = new ServerSocket(8888);
        //监听客户端连接
        Socket socket = ss.accept();
        //从链接通道中获取输入流读取数据
        /*InputStream is = socket.getInputStream();
        InputStreamReader isr = new InputStreamReader(is);
        BufferedReader bis = new BufferedReader(isr);*/
        BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        int c;
        while((c = br.read()) != -1) {
            System.out.print((char)c);
        }
        socket.close();
        ss.close();
    }
}
